﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ProduceBasicData.Api.Application.Command.IncomingMaterialsManage;
using ProduceBasicData.Api.DTO.IncomingMaterialsDto;
using ProduceBasicData.ErrorCode;

namespace ProduceBasicData.Api.Controllers.IncomingMaterialsManage
{
    /// <summary>
    /// 来料检验
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class IncomingInspectionController : ControllerBase
    {
        private readonly IMediator _mediator;
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="mediator"></param>
        public IncomingInspectionController(IMediator mediator)
        {
            _mediator = mediator;
        }
        /// <summary>
        /// 创建来料检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> CreateIncomingInspection(CreateIncomingInspectionCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 获取来料检验列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<ApiResult<IncomingInspectionDto>> GetIncomingInspectionList([FromQuery] GetIncomingInspectionCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 更新来料检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> UpdateIncomingInspection(UpdateIncomingInspectionCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 删除来料检验
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DeleteIncomingInspection(DeleteIncomingInspectionCommand command)
        {
            return await _mediator.Send(command);
        }
        /// <summary>
        /// 来料检验批量删除
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<int>> DeleteRangeIncomingInspection(DeleteRangeIncomingInspectionCommand command)
        {
            return await _mediator.Send(command);
        }
    }
}
